home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / dos / runcommand.c < prev    next >
C/C++ Source or Header  |  1996-10-24  |  3KB  |  126 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: runcommand.c,v 1.8 1996/10/24 15:50:35 aros Exp $
  4.     $Log: runcommand.c,v $
  5.     Revision 1.8  1996/10/24 15:50:35  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.7  1996/10/10 13:22:20  digulla
  9.     Wrong cast (Fleischer)
  10.  
  11.     Revision 1.6  1996/09/13 17:50:09  digulla
  12.     Use IPTR
  13.  
  14.     Revision 1.5  1996/09/11 16:54:23  digulla
  15.     Always use AROS_SLIB_ENTRY() to access shared external symbols, because
  16.     some systems name an external symbol "x" as "_x" and others as "x".
  17.     (The problem arises with assembler symbols which might differ)
  18.  
  19.     Revision 1.4  1996/08/13 13:52:51  digulla
  20.     Replaced <dos/dosextens.h> by "dos_intern.h" or added "dos_intern.h"
  21.     Replaced AROS_LA by AROS_LHA
  22.  
  23.     Revision 1.3  1996/08/01 17:40:57  digulla
  24.     Added standard header for all files
  25.  
  26.     Desc:
  27.     Lang: english
  28. */
  29. #include <exec/memory.h>
  30. #include <clib/exec_protos.h>
  31. #include <utility/tagitem.h>
  32. #include <dos/filesystem.h>
  33. #include <clib/dos_protos.h>
  34. #include "dos_intern.h"
  35.  
  36. LONG AROS_SLIB_ENTRY(RunProcess,Dos)(struct Process *proc,
  37.     struct StackSwapStruct *sss, STRPTR argptr, ULONG argsize,
  38.     LONG_FUNC entry, struct DosLibrary *DOSBase);
  39.  
  40. /*****************************************************************************
  41.  
  42.     NAME */
  43.     #include <clib/dos_protos.h>
  44.  
  45.     AROS_LH4(LONG, RunCommand,
  46.  
  47. /*  SYNOPSIS */
  48.     AROS_LHA(BPTR,   segList,   D1),
  49.     AROS_LHA(ULONG,  stacksize, D2),
  50.     AROS_LHA(STRPTR, argptr,    D3),
  51.     AROS_LHA(ULONG,  argsize,   D4),
  52.  
  53. /*  LOCATION */
  54.     struct DosLibrary *, DOSBase, 84, Dos)
  55.  
  56. /*  FUNCTION
  57.  
  58.     INPUTS
  59.  
  60.     RESULT
  61.  
  62.     NOTES
  63.  
  64.     EXAMPLE
  65.  
  66.     BUGS
  67.  
  68.     SEE ALSO
  69.  
  70.     INTERNALS
  71.  
  72.     HISTORY
  73.     29-10-95    digulla automatically created from
  74.                 dos_lib.fd and clib/dos_protos.h
  75.  
  76. *****************************************************************************/
  77. {
  78.     AROS_LIBFUNC_INIT
  79.     AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
  80.  
  81.     STRPTR oldargs;
  82.     LONG oldresult;
  83.  
  84.     /* Get pointer to process structure */
  85.     struct Process *me=(struct Process *)FindTask(NULL);
  86.  
  87.     UBYTE *stack;
  88.     LONG ret;
  89.     struct StackSwapStruct sss;
  90.  
  91.     stack=(UBYTE *)AllocMem(stacksize,MEMF_ANY);
  92.     if(stack==NULL)
  93.     return -1;
  94.  
  95.     sss.stk_Lower=stack;
  96.     sss.stk_Upper=(IPTR)stack+stacksize;
  97.  
  98.     oldresult=me->pr_Result2;
  99.     if(me->pr_CIS)
  100.     Flush(me->pr_CIS);
  101.     if(me->pr_COS)
  102.     Flush(me->pr_COS);
  103.     if(me->pr_CES)
  104.     Flush(me->pr_CES);
  105.     me->pr_Result2=oldresult;
  106.  
  107.     oldargs=me->pr_Arguments;
  108.     me->pr_Arguments=argptr;
  109.     ret=AROS_SLIB_ENTRY(RunProcess,Dos)(me,&sss,argptr,argsize,
  110.         (LONG_FUNC)((BPTR *)BADDR(segList)+1),DOSBase);
  111.     me->pr_Arguments=oldargs;
  112.  
  113.     oldresult=me->pr_Result2;
  114.     if(me->pr_CIS)
  115.     Flush(me->pr_CIS);
  116.     if(me->pr_COS)
  117.     Flush(me->pr_COS);
  118.     if(me->pr_CES)
  119.     Flush(me->pr_CES);
  120.     me->pr_Result2=oldresult;
  121.  
  122.     FreeMem(stack,stacksize);
  123.     return ret;
  124.     AROS_LIBFUNC_EXIT
  125. } /* RunCommand */
  126.